package GUI;

import java.awt.BasicStroke;
import java.awt.Color;

import javax.swing.JDialog;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;

import Statistics.IDGraphGlobalProperty;

public class DegreeDialog extends JDialog {
	JFreeChart degreeDis;
	DegreeDistributionDataSet dataset;
	public DegreeDialog(String title,IDGraphGlobalProperty idGp)
	{
		super();
		dataset = new DegreeDistributionDataSet(idGp);
		//dataset = new DegreeDistributionDataSet();
		degreeDis = ChartFactory.createScatterPlot("Degree Distribution", "Vertex Degree", "Vertices Counts", dataset, PlotOrientation.VERTICAL, true, true, false);
		XYPlot localXYPlot = (XYPlot)degreeDis.getPlot();
		degreeDis.setBackgroundPaint(Color.gray);
	  
	    
	    localXYPlot.setNoDataMessage("NO DATA");
	    localXYPlot.setDomainPannable(true);
	    localXYPlot.setRangePannable(true);
	    localXYPlot.setDomainZeroBaselineVisible(true);
	    localXYPlot.setRangeZeroBaselineVisible(true);
	    localXYPlot.setDomainGridlineStroke(new BasicStroke(0.0F));
	    localXYPlot.setDomainMinorGridlineStroke(new BasicStroke(0.0F));
	    localXYPlot.setDomainGridlinePaint(Color.blue);
	    localXYPlot.setRangeGridlineStroke(new BasicStroke(0.0F));
	    localXYPlot.setRangeMinorGridlineStroke(new BasicStroke(0.0F));
	    localXYPlot.setRangeGridlinePaint(Color.blue);
	    localXYPlot.setDomainMinorGridlinesVisible(true);
	    localXYPlot.setRangeMinorGridlinesVisible(true);
	    XYLineAndShapeRenderer localXYLineAndShapeRenderer = (XYLineAndShapeRenderer)localXYPlot.getRenderer();
	    localXYLineAndShapeRenderer.setSeriesOutlinePaint(0, Color.red);
	    localXYLineAndShapeRenderer.setUseOutlinePaint(true);
	    NumberAxis localNumberAxis1 = (NumberAxis)localXYPlot.getDomainAxis();
	    localNumberAxis1.setAutoRangeIncludesZero(false);
	    localNumberAxis1.setTickMarkInsideLength(2.0F);
	    localNumberAxis1.setTickMarkOutsideLength(2.0F);
	    localNumberAxis1.setMinorTickCount(2);
	    localNumberAxis1.setMinorTickMarksVisible(true);
	    NumberAxis localNumberAxis2 = (NumberAxis)localXYPlot.getRangeAxis();
	    localNumberAxis2.setTickMarkInsideLength(2.0F);
	    localNumberAxis2.setTickMarkOutsideLength(2.0F);
	    localNumberAxis2.setMinorTickCount(2);
	    localNumberAxis2.setMinorTickMarksVisible(true);
	    localNumberAxis1.setLabelPaint(Color.red);
	    localNumberAxis2.setLabelPaint(Color.red);  
	    localNumberAxis1.setLabelPaint(Color.red);
	    localNumberAxis2.setLabelPaint(Color.red);
	    localNumberAxis1.setTickLabelPaint(Color.red);
	    localNumberAxis2.setTickLabelPaint(Color.red);
	    
	    
		setTitle(title);
		
	    ChartPanel localChartPanel = new ChartPanel(degreeDis);
	    localChartPanel.setMouseWheelEnabled(true);
	    
	    getContentPane().add(localChartPanel);
	}
}
